<?php
session_start();
	$_SESSION['data'] = 'displayAllPublisher';
	
	require_once '../lib/sql.utils.php';
	
	$sql_util = new SqlUtils();
	$result = $sql_util -> getRows('SELECT * FROM publishers');
	$temp = '
		<div class="menu">
			Quản lý NXB > Danh sách NXB
		</div>
		<hr />
		<div class="findbox">
			<select>
				<option>Tên NXB</option>
				<option>Địa chỉ NXB</option>
				<option>Sách đã xuất bản</option>
				<option>Trang chủ</option>
			</select>
			<input type="text" size="25" placeholder="Search..."/>
			<input type="button" value="Tìm kiếm"/>
		</div>
		<hr />
		<table border="0" class="detail">
			<tr class = "detail-head">
				<th>STT</th>
				<th>Tên NXB</th>
				<th>Địa chỉ</th>
				<th>Logo</th>
				<th>Sách đã xuất bản</th>
				<th>Trang chủ</th>
				<th>Ghi chú</th>
				<th>Sửa</th>
				<th><input type="checkbox" id="check"></th>
			</tr>';
			
	for ($i=0; $i < count($result); $i++) { 
		$temp .= '<tr class="detail-main">';
			$temp .= '<td>'. ($i+1) .'</td>';
			$temp .= '<td>'.$result[$i]['publisherName'].'</td>';
			$temp .= '<td>'.$result[$i]['publisherAddress'].'</td>';
			$temp .= '<td><img src="../images/publisher/'.$result[$i]['publisherLogo'].'" width="40px" heigh = "65px" /></td>';
			$temp .= '<td>';
			$result_book = $sql_util -> getRows('SELECT * FROM books WHERE publisherId = '.$result[$i]['publisherId']);
			for($j=0; $j< count($result_book) ; $j++){
				$temp .= $result_book[$j]['bookName'];
				if($j != count($result_book) - 1) $temp .= ',&nbsp';
			}
			$temp .= '</td>';
			$temp .= '<td>'.'<a href="'.$result[0]['publisherHomePage'].'">'.$result[$i]['publisherHomePage'].'</a>'.'</td>';
			$temp .= '<td>'.$result[$i]['publisherDescription'].'</td>';
			$temp .= '<td>'.'<a onclick="displayFormEditPublisher('.$result[$i]['publisherId'].')">Sửa</a>'.'</td>';
			$temp .= '<td>'.'<input type="checkbox" name="check[]">'.'</td>';
		$temp .= '</tr>';
	}
	$temp .= '</table>';
	$temp .= 'Số lượng dòng hiển thị:';
	$temp .= '<select>
				<option>10</option>
				<option>20</option>
				<option>50</option>
			</select>';
	echo $temp;
?>